From: Keir Fraser Date: Fri, 11 Dec 2009 08:57:30 +0000 (+0000) Subject: memory hotadd 6/7: Allocate L3 table for whole direct maping range if X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12923 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:/?a=commitdiff_plain;h=279dee95826094216e2a95db01028b048527cbf8;p=xen.git memory hotadd 6/7: Allocate L3 table for whole direct maping range if memory hotplug is supported. Hot-added memory may need a new L4 entry for 1:1 mapping. This patch setup all L4 entry for 1:1 mapping if memory hotadd is needed, so that we don't need sync the guest page table in page fault handler. Signed-off-by: Jiang, Yunhong --- diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 085d3b205b..e5e0ac8002 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -596,6 +596,32 @@ void __init paging_init(void) l2_pgentry_t *l2_ro_mpt = NULL; struct page_info *l1_pg, *l2_pg, *l3_pg; + /* + * We setup the L3s for 1:1 mapping if host support memory hotplug + * to avoid sync the 1:1 mapping on page fault handler + */ + if ( mem_hotplug ) + { + unsigned long va; + + for ( va = DIRECTMAP_VIRT_START; + va < DIRECTMAP_VIRT_END; + va += (1UL << L4_PAGETABLE_SHIFT) ) + { + if ( !(l4e_get_flags(idle_pg_table[l4_table_offset(va)]) & + _PAGE_PRESENT) ) + { + l3_pg = alloc_domheap_page(NULL, 0); + if ( !l3_pg ) + goto nomem; + l3_ro_mpt = page_to_virt(l3_pg); + clear_page(l3_ro_mpt); + l4e_write(&idle_pg_table[l4_table_offset(va)], + l4e_from_page(l3_pg, __PAGE_HYPERVISOR)); + } + } + } + /* Create user-accessible L2 directory to map the MPT for guests. */ if ( (l3_pg = alloc_domheap_page(NULL, 0)) == NULL ) goto nomem;